package com.example.tliaswebmanagement.controller;

import com.example.tliaswebmanagement.pojo.JobStatistics;
import com.example.tliaswebmanagement.pojo.Result;
import com.example.tliaswebmanagement.pojo.StuStatistics;
import com.example.tliaswebmanagement.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RequestMapping("/report")
@RestController
public class ReportController {
    private final ReportService reportService;

    public ReportController(ReportService reportService) {
        this.reportService = reportService;
    }

    /**
     * 统计员工职位人数
     */
    @GetMapping("/empJobData")
    public Result getEmpJobData() {
        log.info("统计员工职位人数");
        JobStatistics jobStatistics = reportService.getEmpJobData();
        return Result.success(jobStatistics);
    }

    /**
     * 统计不同性别的人数
     */
    @GetMapping("/empGenderData")
    public Result getEmpGenderData() {
        log.info("统计不同性别的人数");
        List<Map<String, Object>> genderList = reportService.getEmpGenderData();
        return Result.success(genderList);
    }

    /**
     * 统计每一个班级的人数
     */
    @GetMapping("/studentCountData")
    private Result getStuData() {
        log.info("统计每一个班级的人数");
        StuStatistics stuData = reportService.getStuData();
        return Result.success(stuData);
    }

    /**
     * 学员学历统计
     */
    @GetMapping("studentDegreeData")
    public Result getDegreeData() {
        log.info("统计学员的学历分布");
        List<Map<String, Object>> degreeData = reportService.getDegreeData();
        return Result.success(degreeData);
    }
}
